package com.did.service;

import com.did.protocol.base.VC.Credential;
import com.did.protocol.request.CreateCredentialParams;


/**
 * @author DELL
 * VC操作的服务接口
 */
public interface CredentialService {
    /**
     * 为一个声明创建VC
     *
     * @param parm 创建VC用到的参数
     * @return VC
     */
    Credential createCredential(CreateCredentialParams parm);

    /**
     * VC签名方法
     *
     * @param credential 待签名VC
     * @param privateKey 发行者的私钥
     * @return 签名后的VC
     */
    Credential addSignature(Credential credential, String privateKey);

    /**
     * 按自定义声明内容生成VC
     *
     * @param credential 待插入声明的VC
     * @param disclosure 声明的待转换字符串格式, 例如: {"name":admin,"password":0,"level":1},
     * @return 插入声明后的VC
     */
    Credential createSelectiveCredential(Credential credential, String disclosure);

    /**
     * 验证VC的合法性，公钥从区块链中获得（多重签名多次验证）
     *
     * @param credential 待验证VC
     * @return 验证结果
     */
    Boolean verify(Credential credential);


    /**
     * 用提供的公钥验证VC
     *
     * @param credential   VC
     * @param didPublicKey 验证签名的公钥
     * @return 验证结果
     */
    Boolean verifyCredentialWithSpecifiedPubKey(Credential credential, String didPublicKey);

    /**
     * 获得完整VC的hash值.
     * todo:确定使用何种HASH
     *
     * @param credential VC
     * @return VC的哈希值
     */
    String getCredentialHash(Credential credential);

    /**
     * 返回VC的JSON格式
     *
     * @param credential VC
     * @return VC的JSON
     */
    String getCredentialJson(Credential credential);
}
